<?php
/**
 * $ModDesc
 * 
 * @version		$Id: file.php $Revision
 * @package		modules
 * @subpackage	$Subpackage.
 * @copyright	Copyright (C) December 2010 LandOfCoder.com <@emai:landofcoder@gmail.com>.All rights reserved.
 * @license		GNU General Public License version 2
 */
if (!defined('_CAN_LOAD_FILES_')){
	define('_CAN_LOAD_FILES_',1);
}    
/**
 * lofcordion Class
 */	
class lofslidorion extends Module
{
	/**
	 * @var LofParams $_params;
	 *
	 * @access private;
	 */
	private $_params = '';	
	/**
	 * @var array $_postErrors;
	 *
	 * @access private;
	 */
	private $_postErrors = array();		
	/**
	 * @var string $__tmpl is stored path of the layout-theme;
	 *
	 * @access private 
	 */	
   /**
    * Constructor 
    */
	function __construct()
	{
		$this->name = 'lofslidorion';
		parent::__construct();			
		$this->tab = 'LandOfCoder';				
		$this->version = '1.0.0';
		$this->displayName = $this->l('Lof Slidorion Module');
		$this->description = $this->l('Lof Slidorion Module');
		if( file_exists( _PS_ROOT_DIR_.'/modules/'.$this->name.'/libs/params.php' ) && !class_exists("LofParams", false) ){
			if( !defined("LOF_SLIDORION_LOAD_LIB_PARAMS") ){				
				require( _PS_ROOT_DIR_.'/modules/'.$this->name.'/libs/params.php' );
				define("LOF_SLIDORION_LOAD_LIB_PARAMS",true);
			}
		}		
		$this->_params = new LofParams( $this->name );		   
	}
   /**
    * process installing 
    */
	function install(){		
		if (!parent::install() || !$this->registerHook('header') || !$this->registerHook('top') || !$this->registerHook('bottomOfHeader'))
			return false;
		return true;
	}
    /*
    * Add Position for site
    */
    function hooklofPresDemo($params){
        return $this->processHook( $params,"lofPresDemo");
    }
	/*
	 * register hook right comlumn to display slide in right column
	 */
	function hookrightColumn($params)
	{		
		return $this->processHook( $params,"rightColumn");
	}
	/*
	 * register hook left comlumn to display slide in left column
	 */
	function hookleftColumn($params)
	{		
		return $this->processHook( $params,"leftColumn");

	}
	function hooktop($params)
	{		
		return '</div><div class="clearfix"></div><div>'.$this->processHook( $params,"top");
	}
	function hookDisplayBottomOfHeader($params)
	{
		return '</div><div class="clearfix"></div><div>'.$this->processHook( $params,"top");
	}
	function hookfooter($params)
	{		
		return $this->processHook( $params,"footer");
	}
	function hookcontenttop($params)
	{ 		
    	return $this->processHook( $params,"contenttop");
	}
	function hookHeader($params)
	{
        
        
		if(_PS_VERSION_ <="1.4"){							
			$header = '
                        <link type="text/css" rel="stylesheet" href="'.($this->_path).'tmpl/'. $this->getParamValue('module_theme','basic').'/assets/style.css'.'" />';
                        
            if( !defined("_LOF_SDION") ){
                $header .='<script type="text/javascript" src="'.($this->_path).'assets/jquery.slidorion.js'.'"></script>
                        <script type="text/javascript" src="'.($this->_path).'assets/jquery.easing.js'.'"></script>';
            
            define('_LOF_SDION', 1); 
                        
            } 
                    
			return $header;			
		}else{
            if( !defined("_LOF_SDION") ){
                Tools::addJS( ($this->_path).'assets/jquery.slidorion.js', 'all');
                Tools::addJS( ($this->_path).'assets/jquery.easing.js', 'all');    
            
            define('_LOF_SDION', 1);           
            } 
             
            Tools::addCSS( ($this->_path).'tmpl/'. $this->getParamValue('module_theme','basic').'/assets/style.css', 'all');
                  
		}
	}
	function hooklofTop($params){
		return $this->processHook( $params,"lofTop");
	}
	function hookHome($params)
	{
		return $this->processHook( $params,"home");
	}
    function hooklofslidorion1($params){
		return $this->processHook( $params,"lofslidorion1");
	}
    function hooklofslidorion2($params){
		return $this->processHook( $params,"lofslidorion2");
	}
    function hooklofslidorion3($params){
		return $this->processHook( $params,"lofslidorion3");
	}
    function hooklofslidorion4($params){
		return $this->processHook( $params,"lofslidorion4");
	}
   
	/**
    * Proccess module by hook
    * $pparams: param of module
    * $pos: position call
    */
	function processHook( $params ){
		global $cookie, $smarty;                
		//load param
		$params = $this->_params;
		$site_url = Tools::htmlentitiesutf8('http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__);
		if(_PS_VERSION_ <="1.4"){
			// create thumbnail folder	 						
			$thumbPath = _PS_IMG_DIR_.$this->name;
			if( !file_exists($thumbPath) ) {
				mkdir( $thumbPath, 0777 );			
			};
			$thumbUrl = $site_url."img/".$this->name;
		}else{			
			// create thumbnail folder	 			
			$thumbPath = _PS_CACHEFS_DIRECTORY_.$this->name;
			if( !file_exists(_PS_CACHEFS_DIRECTORY_) ) {
				mkdir( _PS_CACHEFS_DIRECTORY_, 0777 );  			
			}; 
			if( !file_exists($thumbPath) ) {
				mkdir( $thumbPath, 0777 );
			};
			$thumbUrl = $site_url."cache/cachefs/".$this->name;			
		}
		if( file_exists( _PS_ROOT_DIR_.'/modules/'.$this->name.'/libs/group_base.php' ) && !class_exists("LofSlidorionDataSourceBase", false) ){
			if( !defined("LOF_SLIDORION_LOAD_LIB_GROUP") ) {
				require_once( _PS_ROOT_DIR_.'/modules/'.$this->name.'/libs/group_base.php' );
				define("LOF_SLIDORION_LOAD_LIB_GROUP",true);
			}
		}
		if( file_exists( _PS_ROOT_DIR_.'/modules/'.$this->name.'/libs/phpthumb/ThumbLib.inc.php' ) && !class_exists('PhpThumbFactory', false)){						
			if( !defined("LOF_SLIDORION_LOAD_LIB_PHPTHUMB") ) {
				require( _PS_ROOT_DIR_.'/modules/'.$this->name.'/libs/phpthumb/ThumbLib.inc.php' );	
				define("LOF_SLIDORION_LOAD_LIB_PHPTHUMB",true);
			}
		}
        /*
        * Config Param
        */
        $imgFolder = _PS_IMG_DIR_.$this->name;
        
        $moduleId = rand().time();
        $moduleHeight               =  $params->get("md_height",385);
        $moduleWidth                =  $params->get("md_width",760);
		$theme 			            = $params->get("module_theme","basic");
		$targetlink 	            = $params->get( 'target', '_self' );
		$class 			            = $params->get( 'navigator_pos', 0 ) ? '':'lof-snleft';
		$blockid                    = $this->id;
        $limititem                  = $params->get("limit_items",5);
        $showPrice                  = $params->get("show_price",1);
        $showTipBox                 = $params->get("show_box_tips",1);
        $cremainsize                = $params->get('cre_main_size',1);
        $thumbmainWidth             = $params->get('main_width',500);
        $thumbmainHeight            = $params->get('main_height',385);
        $thumbnailWidth             = $params->get('thumb_width',90);
        $thumbnailHeight            = $params->get('thumb_height',60);
        $maxItemsPerCols            = (int)$params->get( 'per_cols', 3 );
        $numScroll                  = (int)$params->get( 'numscroll', 1 );
        $autoPlay                  = $params->get( 'autoPlay', true );
        $showImage 		            = $params->get( 'showImg', 1 );
        $linkImage 		            = $params->get( 'linkImage', 1 );
        $selectCat                  = $params->get("category","");
        $sliderSpeed 		        = $params->get( 'lof_speed', 800 );
    	$itemSpeed 		            = $params->get( 'lof_duration', 3500 );
    	$effect 		            = $params->get( 'lofeffect', 'fade' );
        $showSubTitle 		        = $params->get( 'sub_title', '1' );
        $showMainTitle 		        = $params->get( 'main_title', '1' );
        $showSubDesc 		        = $params->get( 'sub_desc', '1' );
        $priceReduction 		    = $params->get( 'priceReduction', '1' );
        $linkSubtitle 		        = $params->get( 'linkSubtitle', '1' );
        $itemAtv                    = $params->get("itemAtv",1);
        $featureIcon                = $params->get("feature_icon",1);
        $newIcon                    = $params->get("new_icon",1);
        $saleIcon                   = $params->get("sale_icon",1);
        $showReadmore               = $params->get("show_read",1);
        $itemDateCreated            = $params->get("show_date",1);
        $onlyShow                   = $params->get("only_show",0);
        $maxTitle                   = $params->get("subtitle_max",12);
        $hoverPause                 = $params->get("hoverPause",true);
        $displayModuleicon          = $params->get("dis_icon",1);
        $shadowBox                  = $params->get("shadow_box",1);
        $iconModule = "";
        
        		      
        $params->set( 'auto_renderthumb',0);  
        $ids  = explode(",",$selectCat);
        $token 	= Tools::getToken(false);
		$source =  	  $params->get( 'module_group', 'product' );        
		$path = dirname(__FILE__).'/libs/groups/'.strtolower($source)."/".strtolower($source).'.php';
		if( !file_exists($path) ){
			return array();	
		}
        require_once $path;
        //require_once $path;
        $objectName = "LofSlidorion".ucfirst($source)."DataSource";
	 	$object = new $objectName();		
        $object->setThumbPathInfo($thumbPath,$thumbUrl)
               ->setImagesRendered( array( 'mainImage' => array( (int)$params->get( 'main_width', 550 ), (int)$params->get( 'main_height', 250 )) ) );
        $products = $object->getListByParameters( $params, $ids );
        $total = count($products); 
        
        /**
        * Add check status of products
        */
		$curLang = Language::getLanguage(intval($cookie->id_lang));
		$lofiso_code = $curLang["iso_code"];
        if($source == "product"){
            $imgSize["height"] = $params->get("thumb_height",385);
            $imgSize["width"]  = $params->get("thumb_width",500); 
            $date = date("Y-m-d H:i:s");
            $today = strtotime($date);
            
            foreach ( $products as &$product ) {
                $itemDate = strtotime($product["date_add"]);
                $newnumdays = round(abs($today-$itemDate)/60/60/24);
                $lofdate = date("d F Y", strtotime($product["date_add"]));
                
                $product["classicon"] = "";
                $product["lof_online_only_icon"] = "";
                $product["lof_sale_icon"] = "";
                $product["lof_new_icon"] = "";
                $product["lof_features"] = "";
                if($product["online_only"]==1){
                    $product["lof_online_only_icon"] = "lof-online_only";
                }
                if($product["reduction"]){
                    $product["lof_sale_icon"] = "lof-sale";
                }
                //check new product
                if( $newnumdays < $params->get("timenew",2) && ($params->get("timenew",2) != 0) ){
                    $product["lof_new_icon"] = "lof-new";
                }
                //check feature
                if($product["features"]){
                    $homeFeature =  $this->getProFeature();
                    $checkID = array();
                    foreach($homeFeature as $home){
                        $checkID[] = $home["id_product"];        
                    }
                    if(in_array($product["id_product"],$checkID)){
                        $product["lof_features"] = "lof-feature";    
                    }                  
                }             
            }
            
        }else{
            $dateSlide = '';
            if($params->get("auto_renderthumb",1)){
                $imgSize["height"] = $params->get("main_height",385);
                $imgSize["width"]  = $params->get("main_width",500);    
            }                
        }
        /*
        * End check status of products
        */
        $module_content = '';
        ob_start();
    		 require( dirname(__FILE__).'/tmpl/'.$this->getParamValue('module_theme','basic').'/_content.php' );		
    	    $module_content = ob_get_contents();
    	 ob_end_clean();
        
   		 $navitems = dirname(__FILE__).'/tmpl/'.$this->getParamValue('module_theme','basic').'/_item/lofdetail.tpl';	;
        $lofScript = '';
		ob_start();
		 require( dirname(__FILE__).'/initjs.php' );		
	    $lofScript = ob_get_contents();
	    ob_end_clean();
		// template asignment variables
		$smarty->assign( array(
                              'moduleId'            => $moduleId,
                              'maxItemsPerCols'     => $maxItemsPerCols,
                              'numScroll'           => $numScroll,
                              'showImage'           => $showImage,
                              'itemWidth'           => $itemWidth,
                              'showSubTitle'        => $showSubTitle,
                              'showSubDesc'         => $showSubDesc,
                              'showMainTitle'       => $showMainTitle,
                              'priceReduction'      => $priceReduction,
                              'linkImage'           => $linkImage,
                              'linkSubtitle'        => $linkSubtitle,
                              'lofiso_code'         => $lofiso_code,
                              'showReadmore'        => $showReadmore,
                              'itemDateCreated'     => $itemDateCreated,
                              'onlyShow'            => $onlyShow,
                              'iconModule'          => $iconModule,
                              'cremainsize'         => $cremainsize,
                              'autoPlay'            => $autoPlay,
                              'hoverPause'          => $hoverPause,
                              'itemAtv'             => $itemAtv,
                              'shadowBox'           => $shadowBox,
                              
                              
                              
                              
                              'total'               => $total,
                              'source'              => $source,
                              'module_content'      => $module_content,
                              'navitems'            => $navitems,
                              'lofScript'           => $lofScript,
                              'priceReduction'      => $params->get('priceReduction',1),
						      'object'              => $object,
						      'showAddCart'         => $params->get('add_cart',1),
						      'showDesc'            => $params->get("show_desc",1),
						      'showPrice'           => $showPrice,
						      'perPage'             => $params->get("per_page",4),
						      'effect'              => $effect,
							  'showCaption' 		=> $params->get('show_caption',1),	
							  'widthTooltip' 		=> $params->get('width_tooltip',160),	
							  'moduleHeight'        => $moduleHeight,
							  'moduleWidth'         => $moduleWidth,
							  
							  'autoPlay'            => $params->get('autoPlay',true),
							  'theme'	            => $theme,
							  'limititem'	        => $limititem,
							  'sliderSpeed'	        => $sliderSpeed,
                              'itemSpeed'	        => $itemSpeed,
							  'thumbmainWidth'      => $thumbmainWidth,
							  'thumbmainHeight'     => $thumbmainHeight,
                              'thumbnailWidth'      => $thumbnailWidth,
							  'thumbnailHeight'     => $thumbnailHeight,
							  
							 
							  'lofeffect'           => $params->get('lofeffect',""),
							  'showIconItem'        => $params->get('show_icon',1),
							  					  	
							  'params'		        => $params,							  	
							  'products'		    => $products,
							  'site_url'		    => $site_url,
                              'token' 			    => $token,
                              'checkVersion'	    => _PS_VERSION_,
                              'targetlink'		    => $targetlink,                                							                               
                              'captionWidth'        => $params->get( 'caption_width', 250 ),
                              'postCaption'         => $params->get( 'pos_caption', 'lof-cap-bottom' ),
							  'showTooltip'         => $params->get("show_tooltip",1),
							  'showButton'		    => $params->get('show_button',1),
							  'showDate'		    => $params->get("show_date",1),
                              'publicFixIcon'       => $params->get("publicfixicon","lof-featured-icon")." ".$params->get("publicfixicon","lof-featured-icon").$lofiso_code,
							  'showTitle'           =>$params->get("show_title",1)
						));
        return $this->display(__FILE__, $this->getLayoutPath($theme) ).$lofScript;				
	}
    public function getLayoutPath( $theme ){
        $layout = 'tmpl/'.$theme.'/default.tpl';
        if( !file_exists(__FILE__."/".$layout) ){
            return $layout;
        }
        return 'tmpl/default.tpl';
    }
    public function splitingCols ( $products ){
        return $output; 
    }   	   	   	
   

    
   /**
    * Get list of sub folder's name 
    */
	public function getFolderList( $path ) {
		$items = array();
		$handle = opendir($path);
		if (! $handle) {
			return $items;
		}
		while (false !== ($file = readdir($handle))) {
			if (is_dir($path . $file))
				$items[$file] = $file;
		}
		unset($items['.'], $items['..'], $items['.svn']);
		return $items;
	}
   /**
    * Render processing form && process saving data.
    */	
	public function getContent()
	{
		$html = "";
		if (Tools::isSubmit('submit'))
		{
			$this->_postValidation();
			if (!sizeof($this->_postErrors))
			{													
		        $definedConfigs = array(
		          /* general config */
		          'module_theme'      => '',
		          'per_cols'          => '',
		          'per_page'          => '',
		          'numscroll'         => '',
		          'showImg'           => '',
		          'mousewheel'        => '',
		          'sub_desc'          => '',
		          'main_title'        => '',
		          'sub_title'         => '',
		          'linkImage'         => '',
		          'linkSubtitle'      => '',
		          'show_read'         => '',
		          'show_date'         => '',
		          'only_show'         => '',
		          'date_new'          => '',
		          'subtitle_max'      => '',
		          'priceReduction'    => '',
		          'online_icon'       => '',
		          'feature_icon'      => '',
		          'new_icon'          => '',
		          'sale_icon'         => '',
		          'dis_icon'          => '',
		          'shadowbox'         => '',
		          'bgrshadow'         => '',
		          'bgrshahover'       => '',
		          'bgrmain'           => '',
		          'autoPlay'          => '',
		          'hoverPause'        => '',
                  'itemAtv'           => '',
                  'shadow_box'        => '',
                  
                  
                  
                  //image group
                  'module_group'      => '',
                  'image_folder'      => '',
                  'image_category'    => '',
                  'image_ordering'    => '',                                    
                  //product group
		          'home_sorce'        => '',
                  'order_by'          => '',  
                  'des_max_chars'     => '',                  
                  'sub_max_chars'     => '',                  
                  'publicfixicon'     => '',                  
	              'productids'        => '',                  		          		          		                            		        
	              'show_caption'        => '',                  		          		          		                            		        
	              'show_icon'        => '',                  		          		          		                            		        
	              'limit_cols'        => '',                  		          		          		                            		        
		          
		          'md_height'     => '',
		          'md_width'      => '',
				  'width_tooltip'	      => '',
				  'limit_items'       =>'',
		          /*Main CoinSlider Setting*/
                  'show_tooltip'           => '',
                  'show_button'           => '',
                  'show_image'            => '',
                  'show_desc'        => '',                                  		                            		          
		          'cre_main_size'     => '1',
		          'main_img_size'     => '',
		          'main_height'       => '',
		          'main_width'        => '',
                  'thumb_height'       => '',
		          'thumb_width'        => '',
				  'auto_play' =>'',
		          /*Navigator Setting */
		          'show_price'     => '',
		          'show_title'     => '',
		          'show_date'=> '',
		          'timenewslide'=> '',
		          /*Effect Setting*/
		          'event'           => '',
		          'pause_hover'      => '',
		          'add_cart'          => '',
		          'lof_duration'          => '',
                  'lof_speed'          => '',
		          'lofeffect'            => '',
                  'slide_start'         => '',                  
		          'max_width_expanded'        => '',
		          'target'       =>'',
                  'caption_width'       => '',
                  'show_price'        => ''   , 
                  're_thumb'                => '',
                  'custom-num'              => '',
				  'file_path' => ''
		        );
                $listarticle = Tools::getValue('custom-num');
                $languages = Language::getLanguages();
                foreach($languages as $lan){
                    for( $i=1;$i<=$listarticle;$i++){                       
                        //upload file
                        //echo ($_FILES[$lan["id_lang"]."-".$i."-image"]['name']);die;
                        if (isset($_FILES[$lan["id_lang"]."-".$i."-image"]['name']) && $_FILES[$lan["id_lang"]."-".$i."-image"]['name'] != NULL ){
                          
                            $result = $this->_lofUpload($lan["id_lang"]."-".$i."-image");                       
                            if($result){
                                $imgFolder = _PS_IMG_DIR_.$this->name;
                                $imgFolder = str_replace(_PS_ROOT_DIR_,"",$imgFolder);                                                         
                                $imageLink = __PS_BASE_URI__.$imgFolder."/".$result;
                                $imageLink = str_replace("//","/",$imageLink);
                                
                                $_POST[$lan["id_lang"]."-".$i."-image"] = $imageLink;
                                $definedConfigs[$lan["id_lang"]."-".$i."-image"]  = '';    
                            }else{
                                $html .= "<div>".$this->l("Can't upload file in article")." ".$i."</div>";    
                            }                            						
                        }
						$definedConfigs[$lan["id_lang"]."-".$i."-title"]  = "";
						$definedConfigs[$lan["id_lang"]."-".$i."-type"]  = "";
						$definedConfigs[$lan["id_lang"]."-".$i."-link"]  = "";
						$definedConfigs[$lan["id_lang"]."-".$i."-desc"]  = "";                                                                          
						$definedConfigs[$lan["id_lang"]."-".$i."-price"]  = "";                                                                          
                    }
                }
    			 for($i=1; $i<=10; $i++){
                    $definedConfigs[$i."-enable"]    = "";
                    if(Tools::getValue($i."-enable")){
                        $definedConfigs[$i."-filetype"]  = "";                                        
                        $definedConfigs[$i."-path"]      = "";
                        $definedConfigs[$i."-link"]      = "";                                                                            
                        $definedConfigs[$i."-timer"]     = "";
                        $definedConfigs[$i."-target"]    = "";
                        $definedConfigs[$i."-imagePos"]  = "";
                        $definedConfigs[$i."-pan"]       = "";
                        $definedConfigs[$i."-desc"]      = "";
                        $definedConfigs[$i."-title"]     = ""; 
                        $definedConfigs[$i."-preview"]   = "";
                        $definedConfigs[$i."-pan"]       = "";
                        $definedConfigs[$i."-imagePos"]  = "";
                        $definedConfigs[$i."-timer"]     = "";
                    }                                                          
                }
		        foreach( $definedConfigs as $config => $key ){
		      		Configuration::updateValue($this->name.'_'.$config, Tools::getValue($config), true);
		    	}
                if(Tools::getValue('category')){
    		        if(in_array("",Tools::getValue('category'))){
    		          $catList = "";
    		        }else{
    		          $catList = implode(",",Tools::getValue('category'));  
    		        }
                    Configuration::updateValue($this->name.'_category', $catList, true);
                }
                $linkArray = Tools::getValue('override_links');
                if($linkArray){
                    foreach ($linkArray as $key => $value) {
                        if (is_null($value) || $value == "") {
                            unset ($linkArray[$key]);
                        }
                    }
                    $override_links = implode(",",$linkArray);
                    Configuration::updateValue($this->name.'_override_links', $override_links, true);
                }
				$delText = '';	
		        if(Tools::getValue('delCaImg')){					
					if(_PS_VERSION_ <="1.4"){						
						$cacheFol = _PS_IMG_DIR_.$this->name;												
					}else{			
						$cacheFol = _PS_CACHEFS_DIRECTORY_.$this->name;							
					}					
					if( file_exists( _PS_ROOT_DIR_.'/modules/'.$this->name.'/libs/group_base.php' ) && !class_exists("LofSlidorionDataSourceBase", false) ){
						if( !defined("LOF_SLIDORION_LOAD_LIB_GROUP") ) {
							require_once( _PS_ROOT_DIR_.'/modules/'.$this->name.'/libs/group_base.php' );
							define("LOF_SLIDORION_LOAD_LIB_GROUP",true);
						}
					}
					if (LofDataSourceBase::removedir($cacheFol)){
						$delText =  $this->l('. Cache folder has been deleted');
					}else{
						$delText =  $this->l('. Cache folder can\'tdeleted');
					}  
				}
		        $html .= '<div class="conf confirm">'.$this->l('Settings updated').$delText.'</div>';
			}
			else
			{
				foreach ($this->_postErrors AS $err)
				{
					$html .= '<div class="alert error">'.$err.'</div>';
				}
			}
			// reset current values.
			$this->_params = new LofParams( $this->name );	
		}
		return $html.$this->_getFormConfig();
	}
    
    
    private function _lofUpload($name){
        if (isset($_FILES[$name]['name']) && $_FILES[$name]['name'] != NULL ){
                $ext = substr($_FILES[$name]['name'], strrpos($_FILES[$name]['name'], '.') + 1);
                $attachFileTypes = array("jpg","bmp","gif","png");
                if(in_array($ext, $attachFileTypes)){
                    $uploadFolder = _PS_IMG_DIR_.$this->name;                  
                    if(!is_dir($uploadFolder)){
                        mkdir($uploadFolder, 0777);
                    }                    
          			if(@move_uploaded_file($_FILES[$name]['tmp_name'], $uploadFolder."/".$_FILES[$name]["name"])){
          			   return $_FILES[$name]["name"];   
       			    }else{
       			       return false;
       			    }
          		}else{
          		    return false;     
          		}				
        }
    }
    
    
	/**
	 * Render Configuration From for user making settings.
	 *
	 * @return context
	 */
	private function _getFormConfig(){		
		$html = '';
	    $formats = ImageType::getImagesTypes( 'products' );
	    $themes=$this->getFolderList( dirname(__FILE__)."/tmpl/" );
        $groups=$this->getFolderList( dirname(__FILE__)."/libs/groups/" );
	    ob_start();
	    include_once dirname(__FILE__).'/config/lofslidorion.php'; 
	    $html .= ob_get_contents();
	    ob_end_clean(); 
		return $html;
	}
    public function getProFeature(){
        $sql = 'SELECT DISTINCT p.id_product FROM `'._DB_PREFIX_.'category_product` cp '
             . 'LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` '
             . 'WHERE cp.`id_category` =1';    
       return Db::getInstance()->ExecuteS($sql);
    }
	/**
     * Process vadiation before saving data 
     */
	private function _postValidation()
	{
		if (!Validate::isCleanHtml(Tools::getValue('module_height')))
			$this->_postErrors[] = $this->l('The module height you entered was not allowed, sorry');
		if (!Validate::isCleanHtml(Tools::getValue('module_width')))
			$this->_postErrors[] = $this->l('The module width you entered was not allowed, sorry');
		if (!Validate::isCleanHtml(Tools::getValue('des_max_chars')) || !is_numeric(Tools::getValue('des_max_chars')))
			$this->_postErrors[] = $this->l('The description max chars you entered was not allowed, sorry');
		if (!Validate::isCleanHtml(Tools::getValue('main_height')) || !is_numeric(Tools::getValue('main_height')))
			$this->_postErrors[] = $this->l('The Main Image Height you entered was not allowed, sorry');
		if (!Validate::isCleanHtml(Tools::getValue('main_width')) || !is_numeric(Tools::getValue('main_width')))
			$this->_postErrors[] = $this->l('The Main Image Width you entered was not allowed, sorry');
	}
   /**
    * Get value of parameter following to its name.
    * 
	* @return string is value of parameter.
	*/
	public function getParamValue($name, $default=''){
		return $this->_params->get( $name, $default );	
	}
}



 